﻿Public Class Cpersonal

    Public Shared Function Añadir(ByVal descEmpresa As String, ByVal pPersonal As Epersonal, ByVal pUsuario As Eusuario) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                Dim idPersonal As Integer = 0
                Dim resultadoPersonal As Boolean = Rpersonal.Añadir(descEmpresa, pPersonal, idPersonal)
                pUsuario.idPersonal = idPersonal
                Dim resultadoUsuario As Boolean = Rusuario.Añadir(descEmpresa, pUsuario)
                If resultadoPersonal AndAlso resultadoUsuario Then resultado = True
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Editar(ByVal descEmpresa As String, ByVal pPersonal As Epersonal, ByVal pUsuario As Eusuario) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                Dim resultadoPersonal As Boolean = Rpersonal.Editar(descEmpresa, pPersonal)
                Dim resultadoUsuario As Boolean = Rusuario.Editar(descEmpresa, pUsuario)
                If resultadoPersonal AndAlso resultadoUsuario Then resultado = True
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function

End Class
